package cn.dida.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.dida.model.UserSession;
import cn.dida.service.StaffService;
/**
 * 个人资料
 * @author weiwei
 *
 */
@Controller
public class ProfileController extends BaseController {
    @Autowired
    private StaffService staffService;

    /**
     * 进入个人资料页面
     * @param request
     * @return ModelAndView 个人资料页面
     * @throws Exception
     */
    @GetMapping("/profile")
    public ModelAndView profile(HttpServletRequest request) throws Exception {
        Map<String, Object> model = new HashMap<String, Object>();
        UserSession userSession = getUserSession(request);

        model.put("profile", staffService.getStaff(userSession.getAccount()));
        return new ModelAndView("profile").addAllObjects(model);
    }
}
